<!doctype html>



  


<html class="theme-next mist use-motion" lang="en">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="database," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="Concurrency Control Theory">
<meta property="og:type" content="article">
<meta property="og:title" content="Database System Review 10">
<meta property="og:url" content="https://annashuo.github.io/2017/11/08/database-system-review10/index.html">
<meta property="og:site_name" content="Anna's Blog">
<meta property="og:description" content="Concurrency Control Theory">
<meta property="og:image" content="https://github.com/Annashuo/hello-world/blob/master/dependency_graphs.png?raw=true">
<meta property="og:updated_time" content="2017-11-13T20:04:13.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Database System Review 10">
<meta name="twitter:description" content="Concurrency Control Theory">
<meta name="twitter:image" content="https://github.com/Annashuo/hello-world/blob/master/dependency_graphs.png?raw=true">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"right","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://annashuo.github.io/2017/11/08/database-system-review10/"/>





  <title> Database System Review 10 | Anna's Blog </title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="en">

  
<!-- hexo-inject:begin --><!-- hexo-inject:end --><script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '',
      xfbml      : true,
      version    : 'v2.6'
    });
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>



<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-105321506-1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?6f5ab2ef1e021070500f7228c830f3c6";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Anna's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
    
      <p class="site-subtitle">My heart is in the work...</p>
    
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="https://annashuo.github.io/2017/11/08/database-system-review10/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="Anna">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.gif">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Anna's Blog">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="Anna's Blog" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Database System Review 10
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-11-08T15:09:29-05:00">
                2017-11-08
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/STUDY/" itemprop="url" rel="index">
                    <span itemprop="name">STUDY</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/11/08/database-system-review10/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count fb-comments-count" data-href="https://annashuo.github.io/2017/11/08/database-system-review10/" itemprop="commentCount">0</span> comments
                </a>
              </span>
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="Concurrency-Control-Theory"><a href="#Concurrency-Control-Theory" class="headerlink" title=" Concurrency Control Theory"></a><center> Concurrency Control Theory</center></h2><a id="more"></a>
<h3 id="Transactions"><a href="#Transactions" class="headerlink" title="Transactions"></a>Transactions</h3><p>A <u>transaction</u> is the execution of a sequence of one or more operations on a shared database to perform some higher-level function.</p>
<h4 id="Strawman-System-SQLite"><a href="#Strawman-System-SQLite" class="headerlink" title="Strawman System(SQLite)"></a>Strawman System(SQLite)</h4><p>One and only one txn can be running at the same time in the DBMS. Before a txn starts, copy the entire database to a new file and make all changes to that file.</p>
<h4 id="Formal-Definitions"><a href="#Formal-Definitions" class="headerlink" title="Formal Definitions"></a>Formal Definitions</h4><p>Database: A fixed set of named data objects(A, B, C,…)</p>
<p>Transaction: A sequence of read and write operations(R(A), W(B),…)</p>
<p>In SQL:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">BEGIN</div><div class="line">...</div><div class="line">COMMIT/ABORT</div></pre></td></tr></table></figure>
<h4 id="Atomicity"><a href="#Atomicity" class="headerlink" title="Atomicity"></a>Atomicity</h4><p>Execute all its actions or executes no action at all.</p>
<ul>
<li><p>Approach #1: Logging</p>
<p>  DBMS Logs all actions so that it can undo the actions of aborted txns.</p>
</li>
<li><p>Shadow Paging</p>
<p>  DBMS makes copies of pages and txns make changed to those copies. Only when the txn commits is the page made visible to others.</p>
</li>
</ul>
<h4 id="Consistency"><a href="#Consistency" class="headerlink" title="Consistency"></a>Consistency</h4><ul>
<li>Database Consistency</li>
<li>Transaction Consistency</li>
</ul>
<h4 id="Isolation"><a href="#Isolation" class="headerlink" title="Isolation"></a>Isolation</h4><p>Users submit txns and each txn executes as if it was running by itself.</p>
<p>A <u>concurrency control</u> protocol is how the DBMS decides the proper interleaving of operations from multiple transactions.</p>
<p>Two main categories:</p>
<ul>
<li>Pessimistic: Don’t let problems arise in the first place.</li>
<li>Optimistic: Assume conflicts are rare, deal with them after they happen.</li>
</ul>
<h5 id="Formal-Properties-of-Schedule"><a href="#Formal-Properties-of-Schedule" class="headerlink" title="Formal Properties of Schedule"></a>Formal Properties of Schedule</h5><ul>
<li><strong>Serial Schedule</strong>: A schedule that does not interleave the actions of different txns.</li>
<li><strong>Equivalent Schedules</strong>: The effect of executing the first schedule is identical to the effect of executing the second schedule.</li>
<li><strong>Serializable Schedule</strong>: A schedule that is equivalent to some serial execution of txns.</li>
</ul>
<h5 id="Conflicting-Operations"><a href="#Conflicting-Operations" class="headerlink" title="Conflicting Operations"></a>Conflicting Operations</h5><p>Two operations conflict if:</p>
<ul>
<li>They are by different txns</li>
<li>They are one the same object and at least one of them is a write.</li>
</ul>
<p>Three types:</p>
<ul>
<li>R-W</li>
<li>W-R</li>
<li>W-W</li>
</ul>
<h5 id="Conflict-Serializable-Schedules"><a href="#Conflict-Serializable-Schedules" class="headerlink" title="Conflict Serializable Schedules"></a>Conflict Serializable Schedules</h5><p>Conflict Serializable Schedules S is conflict equivalent to some serial schedule.</p>
<p>Ways to find out a schedule S is conflict serializable:</p>
<ul>
<li>if transform S into a serial schedule by swapping consecutive non-confliting operations of different txns.</li>
<li><p>Dependency Graphs</p>
<p>  <img src="https://github.com/Annashuo/hello-world/blob/master/dependency_graphs.png?raw=true" alt=""></p>
<ul>
<li>Operation $O<em>{i} \in T</em>{i}$</li>
<li>Operation $O<em>{j} \in T</em>{j}$</li>
<li>Operation $O<em>{i} $ and $ O</em>{j}$ conflicts</li>
<li><p>Operation $O<em>{i} $ early than $ O</em>{j}$ </p>
<p>Schedule S is conflict serializable if dependency graph has <strong>no cycle</strong>.</p>
</li>
</ul>
</li>
</ul>
<h5 id="View-Serializability"><a href="#View-Serializability" class="headerlink" title="View Serializability"></a>View Serializability</h5><p>Schedules $S<em>{1}$ and $S</em>{2}$ are view equivalent:</p>
<ul>
<li>if $T<em>{1}$ reads initial value of A in $S</em>{1}$, then $T<em>{1}$ also reads initial value of A in $S</em>{2}$</li>
<li>if $T<em>{1}$ reads value of A written by $T</em>{2}$ in $S<em>{1}$, then $T</em>{1}$ also reads value of A written by $T<em>{2}$ in $S</em>{2}$</li>
<li>if $T<em>{1}$ writes final value of A in $S</em>{1}$, then $T<em>{1}$ also writes final value of A in $S</em>{2}$</li>
</ul>
<h4 id="Durability"><a href="#Durability" class="headerlink" title="Durability"></a>Durability</h4><p>All of the changes of committed txns ahsould be persistent.</p>
<h3 id="Uses-locks-to-guarantee-serializable"><a href="#Uses-locks-to-guarantee-serializable" class="headerlink" title="Uses locks to guarantee serializable"></a>Uses <font style="color:red;">locks</font> to guarantee serializable</h3><h4 id="Lock-Types"><a href="#Lock-Types" class="headerlink" title="Lock Types"></a>Lock Types</h4><h5 id="Locks-and-Latches"><a href="#Locks-and-Latches" class="headerlink" title="Locks and Latches"></a>Locks and Latches</h5><ul>
<li><p>Locks</p>
<ul>
<li>Protects the index’s logical contents from other txns.</li>
<li>Held for txn duration</li>
<li>Need to be able to rollback changes.</li>
</ul>
</li>
<li><p>Latches</p>
<ul>
<li>Protects the critical sections of the index’s internal data structure from other threads</li>
<li>Held for operation duration</li>
<li>Do not need to be able to rollback changes.</li>
</ul>
</li>
</ul>
<div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:center">…</th>
<th style="text-align:center">Locks</th>
<th style="text-align:center">Latches</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">Seperate…</td>
<td style="text-align:center">User txns</td>
<td style="text-align:center">Threads</td>
</tr>
<tr>
<td style="text-align:center">Protect…</td>
<td style="text-align:center">Database contents</td>
<td style="text-align:center">In-Memory Data Structure</td>
</tr>
<tr>
<td style="text-align:center">During…</td>
<td style="text-align:center">Entire txns</td>
<td style="text-align:center">Critical sections</td>
</tr>
<tr>
<td style="text-align:center">Modes…</td>
<td style="text-align:center">Shared, Exclusive, Update, Intention</td>
<td style="text-align:center">Read, Write</td>
</tr>
<tr>
<td style="text-align:center">Deadlock</td>
<td style="text-align:center">Detection &amp; Resolution</td>
<td style="text-align:center">Avoidance</td>
</tr>
<tr>
<td style="text-align:center">…by…</td>
<td style="text-align:center">Waits-for, Timeout, Aborts</td>
<td style="text-align:center">Coding Discipline</td>
</tr>
<tr>
<td style="text-align:center">Kept in…</td>
<td style="text-align:center">Lock Manager</td>
<td style="text-align:center">Protected Data Structure</td>
</tr>
</tbody>
</table>
</div>
<h5 id="Basic-Lock-Types"><a href="#Basic-Lock-Types" class="headerlink" title="Basic Lock Types"></a>Basic Lock Types</h5><ul>
<li>S-LOCK: Shared locks for reads</li>
<li>X-LOCK: Exclusive locks for writes</li>
</ul>
<p>Compatibility Matrix</p>
<div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:center"></th>
<th style="text-align:center">Shared</th>
<th style="text-align:center">Exclusive</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">Shared</td>
<td style="text-align:center">yes</td>
<td style="text-align:center">no</td>
</tr>
<tr>
<td style="text-align:center">Exclusive</td>
<td style="text-align:center">no</td>
<td style="text-align:center">no</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Two-Phase-Locking"><a href="#Two-Phase-Locking" class="headerlink" title="Two-Phase Locking"></a>Two-Phase Locking</h4><p>Two-Phase Locking(2PL) is a concurrency control protocol that determines whether a txn is allowed to access an object in the database on the fly.</p>
<ul>
<li>Phase 1: Growing<ul>
<li>Each txn requests the locks that it needs from the DBMS’s lock manager</li>
<li>The lock manager grants/denies lock requests</li>
</ul>
</li>
<li>Phase 2: Shrinking<ul>
<li>The txn is allowed to only release locks that it previously acquired. It cannot acquire new locks.</li>
</ul>
</li>
</ul>
<p><strong>Two-Phase Locking on its own is sufficient to guarantee conflic serializability. But it is subject to cascading aborting.</strong></p>
<h5 id="2PL-Cascading-Aborts"><a href="#2PL-Cascading-Aborts" class="headerlink" title="2PL-Cascading Aborts"></a>2PL-Cascading Aborts</h5><p>One aborted txn may cause other txn aborts.</p>
<h5 id="Problems-about-2PL"><a href="#Problems-about-2PL" class="headerlink" title="Problems about 2PL"></a>Problems about 2PL</h5><ul>
<li>There are potential schedules that are serializable but would not be allowed by 2PL. Locking limits concurrency.</li>
<li>May still have “dirty read”-&gt;Solution: <strong>Strict 2PL</strong></li>
<li>May lead to deadlocks-&gt;Solutions: <strong>Detection</strong> of <strong>Prevention</strong></li>
</ul>
<h4 id="Strict-Two-Phase-Locking"><a href="#Strict-Two-Phase-Locking" class="headerlink" title="Strict Two-Phase Locking"></a>Strict Two-Phase Locking</h4><p>A schedule is <u>strict</u> if a value written by a txn is not read or overwritten by other txns until that txn finishes.</p>
<p>Advantages:</p>
<ul>
<li>Does not incur cascading aborts</li>
<li>Aborted txns can be undone by just restoring original values of modified tuples.</li>
</ul>
<h4 id="Deadlock-Detection-Prevention"><a href="#Deadlock-Detection-Prevention" class="headerlink" title="Deadlock Detection + Prevention"></a>Deadlock Detection + Prevention</h4><p>A <u>deadlock</u> is a cycle of transactions waiting for locks to be released by each other.</p>
<h5 id="Deadlock-Detection"><a href="#Deadlock-Detection" class="headerlink" title="Deadlock Detection"></a>Deadlock Detection</h5><p><strong>Wait-for</strong> Graph: Nodes are txns, Edge fro $T<em>{i}$ to $T</em>{j}$ if $T<em>{i}$ is waiting for $T</em>{j}$ to release a lock. Check for cycles and make a decision to break it.</p>
<p><strong>Deadlock Handling</strong>:</p>
<ul>
<li>Victim Selection(by age, by progress, by the # of items already locked, by the # of txns that we have to rollback with it), Also consider the # of times a txn has been restarted in the past.</li>
<li>Rollback Length: Completely or Minimally</li>
</ul>
<h5 id="Deadlock-Prevention"><a href="#Deadlock-Prevention" class="headerlink" title="Deadlock Prevention"></a>Deadlock Prevention</h5><p>Priority: older-&gt; higher priority.</p>
<ul>
<li><strong>Wait-Die</strong>(Old waits for Young): If $T<em>{i}$ has higher priority, $T</em>{i}$ waits for $T<em>{j}$, otherwise $T</em>{i}$ aborts</li>
<li><strong>wound-wait</strong>(Young waits for Old): If $T<em>{i}$ has higher priority, $T</em>{j}$ abort, otherwise $T_{i}$ waits.</li>
</ul>
<p><strong>When a txn restarts, its new priority is original timestamp.</strong></p>
<h4 id="Hierarchical-Locking"><a href="#Hierarchical-Locking" class="headerlink" title="Hierarchical Locking"></a>Hierarchical Locking</h4><h5 id="Intention-Locks"><a href="#Intention-Locks" class="headerlink" title="Intention Locks"></a>Intention Locks</h5><p>A <u>intention lock</u> allows a higher level node to be locked in shared or exclusive mode without having to check all descendent nodes.</p>
<ul>
<li>Intention-Shared(IS): Indicates explicit locking at a lower level with shared locks.</li>
<li>Intention-Exclusive(IX): Indicates locking at lower level with excludive or shared locks.</li>
<li>Shared+Intention-Exclusive(SIX): The subtree rooted by that node is locked explicitly in shared mode and explicit locking is being done at lower level with exclusive-mode locks. Like S and IX at the same time.</li>
</ul>
<p>Compatibility Matrix:</p>
<div class="table-container">
<table>
<thead>
<tr>
<th style="text-align:center">…</th>
<th style="text-align:center">IS</th>
<th style="text-align:center">IX</th>
<th style="text-align:center">S</th>
<th style="text-align:center">SIX</th>
<th style="text-align:left">X</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">IS</td>
<td style="text-align:center">y</td>
<td style="text-align:center">y</td>
<td style="text-align:center">y</td>
<td style="text-align:center">y</td>
<td style="text-align:left">n  </td>
</tr>
<tr>
<td style="text-align:center">IX</td>
<td style="text-align:center">y</td>
<td style="text-align:center">y</td>
<td style="text-align:center">n</td>
<td style="text-align:center">n</td>
<td style="text-align:left">n</td>
</tr>
<tr>
<td style="text-align:center">S</td>
<td style="text-align:center">y</td>
<td style="text-align:center">n</td>
<td style="text-align:center">y</td>
<td style="text-align:center">n</td>
<td style="text-align:left">n</td>
</tr>
<tr>
<td style="text-align:center">SIX</td>
<td style="text-align:center">y</td>
<td style="text-align:center">n</td>
<td style="text-align:center">n</td>
<td style="text-align:center">n</td>
<td style="text-align:left">n</td>
</tr>
<tr>
<td style="text-align:center">X</td>
<td style="text-align:center">n</td>
<td style="text-align:center">n</td>
<td style="text-align:center">n</td>
<td style="text-align:center">n</td>
<td style="text-align:left">n</td>
</tr>
</tbody>
</table>
</div>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/database/" rel="tag"># database</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/11/07/database-system-review09/" rel="next" title="Database System Review 09">
                <i class="fa fa-chevron-left"></i> Database System Review 09
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/11/09/database-system-review11/" rel="prev" title="Database System Review 11">
                Database System Review 11 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="fb-comments"
           data-href="https://annashuo.github.io/2017/11/08/database-system-review10/"
           data-numposts="10"
           data-width="100%"
           data-colorscheme="light">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="Anna" />
          <p class="site-author-name" itemprop="name">Anna</p>
          <p class="site-description motion-element" itemprop="description">My heart is in the work...</p>
        </div>
        <nav class="site-state motion-element">
        
          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">43</span>
                <span class="site-state-item-name">posts</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">6</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">12</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/Annashuo/Annashuo.github.io" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/u/1861044584?is_all=1" target="_blank" title="Weibo">
                  
                    <i class="fa fa-fw fa-weibo"></i>
                  
                  Weibo
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Concurrency-Control-Theory"><span class="nav-number">1.</span> <span class="nav-text"> Concurrency Control Theory</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Transactions"><span class="nav-number">1.1.</span> <span class="nav-text">Transactions</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Strawman-System-SQLite"><span class="nav-number">1.1.1.</span> <span class="nav-text">Strawman System(SQLite)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Formal-Definitions"><span class="nav-number">1.1.2.</span> <span class="nav-text">Formal Definitions</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Atomicity"><span class="nav-number">1.1.3.</span> <span class="nav-text">Atomicity</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Consistency"><span class="nav-number">1.1.4.</span> <span class="nav-text">Consistency</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Isolation"><span class="nav-number">1.1.5.</span> <span class="nav-text">Isolation</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Formal-Properties-of-Schedule"><span class="nav-number">1.1.5.1.</span> <span class="nav-text">Formal Properties of Schedule</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Conflicting-Operations"><span class="nav-number">1.1.5.2.</span> <span class="nav-text">Conflicting Operations</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Conflict-Serializable-Schedules"><span class="nav-number">1.1.5.3.</span> <span class="nav-text">Conflict Serializable Schedules</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#View-Serializability"><span class="nav-number">1.1.5.4.</span> <span class="nav-text">View Serializability</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Durability"><span class="nav-number">1.1.6.</span> <span class="nav-text">Durability</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Uses-locks-to-guarantee-serializable"><span class="nav-number">1.2.</span> <span class="nav-text">Uses locks to guarantee serializable</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Lock-Types"><span class="nav-number">1.2.1.</span> <span class="nav-text">Lock Types</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Locks-and-Latches"><span class="nav-number">1.2.1.1.</span> <span class="nav-text">Locks and Latches</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Basic-Lock-Types"><span class="nav-number">1.2.1.2.</span> <span class="nav-text">Basic Lock Types</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Two-Phase-Locking"><span class="nav-number">1.2.2.</span> <span class="nav-text">Two-Phase Locking</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#2PL-Cascading-Aborts"><span class="nav-number">1.2.2.1.</span> <span class="nav-text">2PL-Cascading Aborts</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Problems-about-2PL"><span class="nav-number">1.2.2.2.</span> <span class="nav-text">Problems about 2PL</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Strict-Two-Phase-Locking"><span class="nav-number">1.2.3.</span> <span class="nav-text">Strict Two-Phase Locking</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Deadlock-Detection-Prevention"><span class="nav-number">1.2.4.</span> <span class="nav-text">Deadlock Detection + Prevention</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Deadlock-Detection"><span class="nav-number">1.2.4.1.</span> <span class="nav-text">Deadlock Detection</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Deadlock-Prevention"><span class="nav-number">1.2.4.2.</span> <span class="nav-text">Deadlock Prevention</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Hierarchical-Locking"><span class="nav-number">1.2.5.</span> <span class="nav-text">Hierarchical Locking</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Intention-Locks"><span class="nav-number">1.2.5.1.</span> <span class="nav-text">Intention Locks</span></a></li></ol></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Anna</span>
</div>


<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	





  





  

  
      <!-- UY BEGIN -->
      <script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid="></script>
      <!-- UY END --><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({"tex2jax":{"inlineMath":[["$","$"],["\\(","\\)"]],"skipTags":["script","noscript","style","textarea","pre","code"],"processEscapes":true},"TeX":{"equationNumbers":{"autoNumber":"AMS"}}});
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->
  




  
  

  
  


  

  

  


</body>
</html>
